package guda.house.biz.form.village;

import guda.house.dal.dataobject.VillageDO;

import javax.validation.constraints.NotNull;
import java.text.SimpleDateFormat;

/**
 * Created by well on 15/11/12.
 */
public class VillageEditForm extends VillageForm{

    @NotNull(message = "不能为空")
    private Long villageId;

    public void initForm(VillageDO villageDO){
        setVillageId(villageDO.getVillageId());
        setVillageAddr(villageDO.getVillageAddr());
        setVillageName(villageDO.getVillageName());
        setVillageStatus(villageDO.getVillageStatus());
        setEstateId(villageDO.getEstateId());
        setStreetCode(villageDO.getStreetCode());

        if(villageDO.getGmtDelivery()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtDelivery(simpleDateFormat.format(villageDO.getGmtDelivery()));
        }
    }

    public VillageDO toDO(){
        VillageDO villageDO = super.toDO();
        villageDO.setVillageId(villageId);
        return villageDO;
    }

    public Long getVillageId() {
        return villageId;
    }

    public void setVillageId(Long villageId) {
        this.villageId = villageId;
    }
}
